// 模拟后端动态生成路由
import { defineFakeRoute } from "vite-plugin-fake-server/client";

/**
 * roles：页面级别权限，这里模拟二种 "admin"、"common"
 * admin：管理员角色
 * common：普通角色
 */
// const permissionRouter = {
//   path: "/permission",
//   meta: {
//     title: "权限管理",
//     icon: "ep:lollipop",
//     rank: 10
//   },
//   children: [
//     {
//       path: "/permission/page/index",
//       name: "PermissionPage",
//       meta: {
//         title: "页面权限",
//         roles: ["admin", "common"]
//       }
//     },
//     {
//       path: "/permission/button/index",
//       name: "PermissionButton",
//       meta: {
//         title: "按钮权限",
//         roles: ["admin", "common"],
//         auths: [
//           "permission:btn:add",
//           "permission:btn:edit",
//           "permission:btn:delete"
//         ]
//       }
//     }
//   ]
// };

const routerConfig = [
  // permissionRouter,
  {
    path: "/toolRoom",
    name: "ToolRoom",
    meta: {
      title: "工具室",
      icon: "ep:house"
    },
    children: [
      {
        path: "/toolRoom/index",
        name: "ToolRoomIndex",
        meta: { title: "工具室" }
      }
    ]
  },

  {
    path: "/toolEquipment",
    name: "ToolEquipment",
    meta: {
      title: "工具室设施",
      icon: "ep:scale-to-original"
    },
    children: [
      {
        path: "/toolEquipment/index",
        name: "ToolIndex",
        meta: { title: "工具室设施" }
      }
    ]
  },
  {
    path: "/depot",
    name: "Depot",
    meta: {
      title: "库存管理",
      icon: "ep:message-box"
    },
    children: [
      {
        path: "/depot/search",
        name: "DepotSearch",
        meta: { title: "库存查询" }
      },
      {
        path: "/depot/record/index",
        name: "DepotRecord",
        meta: { title: "盘点记录" }
      },
      {
        path: "/depot/record/detail",
        name: "DepotRecordDetail",
        meta: { title: "盘点记录详情", showLink: false, showParent: true }
      },
      {
        path: "/depot/misplaced",
        name: "DepotMisplaced",
        meta: { title: "错放清单" }
      }
    ]
  },
  {
    path: "/borrowReturn",
    name: "BorrowReturn",
    meta: {
      title: "借还记录",
      icon: "ep:connection"
    },
    children: [
      {
        path: "/borrowReturn/record",
        name: "BorrowReturnRecord",
        meta: { title: "借还记录" }
      },
      {
        path: "/borrowReturn/noReturn",
        name: "BorrowReturnNoReturn",
        meta: { title: "未归还" }
      }
    ]
  },
  {
    path: "/overhaul",
    name: "Overhaul",
    meta: {
      title: "定检报修",
      icon: "ep:clock"
    },
    children: [
      {
        path: "/overhaul/nocheck",
        name: "OverhaulNocheck",
        meta: {
          title: "检查记录"
        }
      },
      {
        path: "/overhaul/repair",
        name: "OverhaulRepair",
        meta: {
          title: "报修记录"
        }
      },
      {
        path: "/overhaul/maintenance",
        name: "OverhaulMaintenance",
        meta: {
          title: "维修记录"
        }
      }
    ]
  },
  {
    path: "/statistics",
    name: "Statistics",
    meta: {
      title: "数据统计",
      icon: "ep:data-line"
    },
    children: [
      {
        path: "/statistics/staff",
        name: "StatisticsStaff",
        meta: { title: "人员借还" }
      },
      {
        path: "/statistics/tool",
        name: "StatisticsTool",
        meta: { title: "工具使用" }
      },
      {
        path: "/statistics/toolRepair",
        name: "StatisticsToolRepair",
        meta: { title: "工具报修" }
      },
      {
        path: "/statistics/shelves",
        name: "StatisticsShelves",
        meta: { title: "货架" }
      }
    ]
  },
  {
    path: "/system",
    name: "System",
    meta: {
      title: "系统管理",
      icon: "ep:setting"
    },
    children: [
      {
        path: "/system/user/index",
        name: "SystemUser",
        meta: { title: "用户管理" }
      },
      {
        path: "/system/role/index",
        name: "SystemRole",
        meta: { title: "角色管理" }
      }
    ]
  }
];

export default defineFakeRoute([
  {
    url: "/get-async-routes",
    method: "get",
    response: () => {
      return {
        success: true,
        data: routerConfig
      };
    }
  }
]);
